﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace hostal
{
    public partial class GestionConsumo : Form
    {
        DataTable temp = new DataTable();
        public GestionConsumo()
        {
            InitializeComponent();
        }

        private void GestionConsumo_Load(object sender, EventArgs e)
        {
            DGHabs.Columns.Clear();
            habitacionDataAccess hDal = new habitacionDataAccess();
            temp = hDal.buscarHabitacionesOcupadas();
            DGHabs.DataSource = temp;
            DGHabs.Columns[0].Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int fila = DGHabs.CurrentRow.Index;
                if (fila != -1)
                {
                    AgregarConsumo m = new AgregarConsumo(DGHabs.Rows[fila].Cells[1].Value.ToString());
                    m.ShowDialog();
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int fila = DGHabs.CurrentRow.Index;
                if (fila != -1)
                {
                    VerConsumo m = new VerConsumo(DGHabs.Rows[fila].Cells[1].Value.ToString());
                    m.ShowDialog();
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
